package com.tools.module.base.web;

import com.tools.common.config.AbstractController;
import com.tools.common.model.Result;
import com.tools.common.util.DateUtils;
import com.tools.common.util.ShiroUtils;
import com.tools.module.base.entity.BaseRecruit;
import com.tools.module.base.service.BaseRecruitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/base/recruit")
public class BaseRecruitController extends AbstractController {

    @Autowired
    private BaseRecruitService recruitService;

    /**
     * 列表
     */
    @PostMapping("/list")
    public Result list(BaseRecruit recruit){
        return recruitService.list(recruit);
    }
    /**
     * 查询
     */
    @PostMapping("/get")
    public Result get(Long id){
        return recruitService.get(id);
    }
    /**
     * 保存
     */
    @PostMapping("/save")
    public Result save(@RequestBody BaseRecruit recruit){
        if (recruit.getId()==null){
            recruit.setCreateTime(DateUtils.getTimestamp());
            recruit.setCreateUid(ShiroUtils.getUserId());
        }
        recruit.setUpdateUid(ShiroUtils.getUserId());
        return recruitService.save(recruit);
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public Result delete(Long id){
        return recruitService.delete(id);
    }
}
